﻿using System;
using Microsoft.Xna.Framework;

namespace XNAGameEngine.Pathfinding
{
    struct PathfindingCell : IComparable<PathfindingCell>
    {
        /// <summary>
        /// The heuristic cost to the goal
        /// </summary>
        internal double _hCost;

        /// <summary>
        /// The movement cost incurred so far
        /// </summary>
        internal double _gCost;

        /// <summary>
        /// The reference to the cell which comes before this one in the final
        /// path
        /// </summary>
        internal Point _previousCell;

        /// <summary>
        /// This cells location in the _cellMap
        /// </summary>
        internal Point _location;

        /// <summary>
        /// Get _hCost + _gCost
        /// </summary>
        internal double TotalCost { get { return _hCost + _gCost; } }

        #region IComparable<PathfindingCell> Members

        /// <summary>
        /// Compares this PathfindingCell to the one passed in
        /// </summary>
        /// <param name="other">the PathfindingCell to compare</param>
        /// <returns>1 if this cell is greater</returns>
        public int CompareTo(PathfindingCell other)
        {
            return TotalCost > other.TotalCost
                       ? 1 : (TotalCost < other.TotalCost ? -1 : 0);
        }

        #endregion
    }
}
